#include<bits/stdc++.h>
#define LL long long
#define db double
#define pii pair<int, int>
#define fi first
#define se second

using namespace std;

const int N = 2e5 + 10;
const int INF = 1e9 + 7;
const LL INFF = 1e17 + 7;
const int mod = 1e9 + 7;

LL n, m, L, V;
LL p[N];
LL tot;
struct node {
    LL d, v, a;
} a[N];
struct line {
    int l, r;
    bool operator < (const line &kkk) const {
        return r < kkk.r;
    }
} q[N];

void solve()
{
    cin >> n >> m >> L >> V;
    for(int i = 1; i <= n; i++) {
        cin >> a[i].d >> a[i].v >> a[i].a;
    }
    for(int i = 1; i <= m; i++) {
        cin >> p[i];
    } sort(p+1, p+m+1);
    int ans1 = 0; tot = 0;
    for(int i = 1; i <= n; i++) {
        if(a[i].a < 0) {
            int l = lower_bound(p+1, p+m+1, a[i].d) - p, r = m, flg = 0;
            if(l > r) continue;
            LL v0 = a[i].v, d = a[i].d;
            if(v0 * v0 + 2ll * (p[l] - d) * a[i].a <= V * V) continue;
            q[++tot].l = l; ans1++;
            while(l <= r) {
                int mid = l + r >> 1;
                if(v0*v0 + 2ll * (p[mid] - d) * a[i].a > V*V) {
                    flg = mid;
                    l = mid + 1;
                } else {
                    r = mid - 1;
                }
            }
            q[tot].r = flg;
        } else {
            int l = lower_bound(p+1, p+m+1, a[i].d) - p, r = m, flg = 0;
            if(l > r) continue;
            LL v0 = a[i].v, d = a[i].d;
            while(l <= r) {
                int mid = l + r >> 1;
                if(v0*v0 + 2ll * (p[mid] - d) * a[i].a > V*V) {
                    flg = mid;
                    r = mid - 1;
                } else {
                    l = mid + 1;
                }
            }
            if(flg) ans1++;
            q[++tot].l = flg, q[tot].r = m;
        }
    } sort(q+1, q+tot+1);
   // for(int i = 1; i <= tot; i++) cout << q[i].l << " " << q[i].r << endl;

    int ans2 = 0;
    for(int i = 1, mx = -1; i <= tot; i++) {
        if(q[i].l <= mx) continue;
        ans2++;
        mx = q[i].r;
    }

    cout << ans1 << " " << m - ans2 << endl;
}

int main()
{
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);

    ios::sync_with_stdio(0);

    int T;
    cin >> T;
    while(T--) solve();

    return 0;
}
